Component({
  properties: {
    defaultVal: {
      type: Boolean,
      value: false,
      observer(newVal, oldVal, changedPath) {
        this.setData({ checked: newVal })
      }
    },
  },
  data: {
    checked: false
  },
  methods: {
    handleSwitch() {
      this.setData({ checked: !this.data.checked })
      this.triggerEvent('siwtchEvent', this.data.checked)
    },
    handleChecked(e) {
      console.log('handleChecked', e)
      const checked = e
      this.setData({ checked })
    }
  },
  lifetimes: {
    ready() {
      this.setData({ checked: this.properties.defaultVal })
    }
  },
})
